package com.plugin.manage.controller;

import com.plugin.core.bean.LogAop;
import com.plugin.manage.pojo.dto.ElderBookingInfoDTO;
import com.plugin.manage.common.PageResult;
import com.plugin.manage.common.RespObj;
import com.plugin.manage.service.IElderBookingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 床位预订管理控制器
 * 
 * @author mark
 * @date 2025-08-01
 */
@RestController
@RequestMapping("/booking")
@Tag(name = "床位预订管理", description = "床位预订相关接口")
@Slf4j
public class BookingBedController {

    @Autowired
    private IElderBookingService elderBookingService;

    /**
     * 获取所有老人预订床位信息
     * 三表联查：elder_info, elder_check_in, elder_consultation
     */
    @PostMapping("/elderBookingInfo")
    @Operation(summary = "获取老人预订床位信息", description = "三表联查获取老人预订床位详细信息")
    @LogAop(remark = "获取老人预订床位信息")
    public RespObj<?> getElderBookingInfo( @Parameter(description = "当前页码（从1开始）", example = "1")
                                               @RequestParam(defaultValue = "1") Long current,

                                           @Parameter(description = "每页数量", example = "10")
                                               @RequestParam(defaultValue = "10") Long size) {
        try {
            PageResult<ElderBookingInfoDTO> result = elderBookingService.getElderBookingInfo(current,size);
            return new RespObj<PageResult<ElderBookingInfoDTO>>().success(result);
        } catch (Exception e) {
            log.error("获取老人预订床位信息失败", e);
            return new RespObj<List<ElderBookingInfoDTO>>().error("获取老人预订床位信息失败：" + e.getMessage());
        }
    }


}
